/*******************************************************************************
 * StandardDataUpdater.h
 *
 * Copyright (c) 2012, Varuna L Amachi. All rights reserved.
 *
 * This program/library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This program/library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA 02110-1301  USA
 ******************************************************************************/

#ifndef STANDARDDATAUPDATER_H
#define STANDARDDATAUPDATER_H

#include "IDataUpdater.h"



namespace Tanyatu
{
namespace Model {
    class StoredVideo;
    class ArtistInfo;
    class AlbumInfo;
}
namespace DataSource
{
class TANYATU_CORE_EXPORT StandardDataUpdater : public IDataUpdater
{
public:
    StandardDataUpdater(){}

    ~StandardDataUpdater(){}

    bool add( Model::StoredObject *stored );

    bool update( Model::StoredObject *stored );

    bool remove( Model::StoredObject *stored );

    bool add( QList< Model::StoredObject *> &objList );

    bool update( QList< Model::StoredObject *> &objList );

    bool remove(QList<Model::StoredObject *> &objList );

    bool savePlaylist( QString playlistName,
                               QList< QString > ids );

    bool addHistory( QString itemId, QDateTime time );

    //Settings framework will come later, this for sample :P
    bool updateSetting( QString key, QVariant value );

    bool clearAudioLibrary();

    bool clearVideoLibrary();

    bool clearHistory();

    bool clearHistory( QDateTime &from );

    bool clearPlaylist( QString playlistName );

    bool removePlaylist( QString playlistName );

//    bool appendTrackToPlaylist( QString playlistName,
//                                QString trackId,
//                                int index );


    bool removeAudioTracks( QList< QString > &trackIds );

    bool removeAudioTrack( QString trackId );

    bool removeVideoTracks( QList< QString > &trackIds );

    bool removeVideoTrack( QString trackId );

    bool removeArtist( QString artistName );

    bool removeAlbum( QString albumId );

    bool removeHistoryItem( QString trackId );

    bool removeFromHistory( QList< QString > &trackIds );

    bool updateRating( Model::StoredMediaObject *stored );

    bool updatePlayCount( Model::StoredMediaObject *stored );

    bool updateTags( Model::StoredMediaObject *stored );

    bool saveCurrentPlaylist( const QList< Tanyatu::Model::MediaItem *> &list );

private:
    bool add( Model::StoredAudio *audio );

    bool add( Model::StoredVideo *video );

    bool add( Model::SavedPlaylist *playlist );

    bool add( Model::ArtistInfo *artist );

    bool add( Model::AlbumInfo *album );

    bool update( Model::StoredAudio *audio );

    bool update( Model::StoredVideo *video );

    bool update( Model::SavedPlaylist *playlist );

    bool update( Model::ArtistInfo *artist );

    bool update( Model::AlbumInfo *album );

//    bool removeTrackRefs( QString trackId );

    QString getTagString( const QSet<QString> &tags );

    QString getTableName( Model::StoredMediaObject *stored );

    QString getUniqueColumnName( Model::StoredMediaObject *stored );

};
}
}

#endif // STANDARDDATAUPDATER_H
